
package guipk;

import commonpk.DBOperation;
import java.sql.SQLException;


public class CountryInfoFrame extends javax.swing.JFrame {

    //************************************************************
    /* 成员 */
    private DBOperation    DBO;                    // 数据库操作
    private String         countryChineseBrief;    // 中文简称
    private String         countryEnglishBrief;    // 英文简称
    private String         countryInfo;            // 国家简介
    //************************************************************
    
    
    
    //****************************************************
    /* 构造器 */
    public CountryInfoFrame() {
        initComponents();
        setLocationRelativeTo(null);
        setVisible(true);
        this.DBO = new DBOperation();
    }
    //****************************************************
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        countryChineseBriefTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        countryNameLabel = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        countryEnglishBriefLabel = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        countryTypeLabel = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        countryInfoLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        countryChineseBriefTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                countryChineseBriefTextFieldActionPerformed(evt);
            }
        });
        jPanel1.add(countryChineseBriefTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(187, 23, 155, -1));

        jLabel1.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel1.setText("输入国家中文简称");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(29, 23, -1, -1));

        jLabel2.setText("国家全称");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 70, -1, -1));
        jPanel1.add(countryNameLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 60, 240, 30));

        jLabel3.setText("英文简称");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 110, -1, -1));
        jPanel1.add(countryEnglishBriefLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 100, 180, 30));

        jLabel5.setText("发展阶段");
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 150, -1, -1));
        jPanel1.add(countryTypeLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 150, 180, 30));

        jLabel4.setText("国家简介");
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 188, -1, 30));
        jPanel1.add(countryInfoLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 190, 340, 30));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void countryChineseBriefTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_countryChineseBriefTextFieldActionPerformed
        // TODO add your handling code here:
        this.countryChineseBrief = this.countryChineseBriefTextField.getText();
        
        // 生成查询语句
        String sql = "select * from CountryTable where countryChineseBrief='" + this.countryChineseBrief + "'";
        //执行 查询语句
        this.DBO.DBQuary(sql);
        
        try{
            this.DBO.getRs().first();
            this.countryNameLabel.setText(this.DBO.getRs().getString("countryName"));
            this.countryEnglishBriefLabel.setText(this.DBO.getRs().getString("countryEnglishBrief"));
            this.countryTypeLabel.setText(this.DBO.getRs().getString("countryType"));
            this.countryInfoLabel.setText(this.DBO.getRs().getString("countryInfo"));
        }catch(SQLException e){
            e.printStackTrace();
        }
        
       
        
    }//GEN-LAST:event_countryChineseBriefTextFieldActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CountryInfoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CountryInfoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CountryInfoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CountryInfoFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CountryInfoFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField countryChineseBriefTextField;
    private javax.swing.JLabel countryEnglishBriefLabel;
    private javax.swing.JLabel countryInfoLabel;
    private javax.swing.JLabel countryNameLabel;
    private javax.swing.JLabel countryTypeLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
